using System;
using System.Text;
using System.Drawing;

 #if (WinForms)
    using System.Windows.Forms;
 #else
    using cs2335.CCT;
 #endif

namespace cs2335.lab6
{
    #if (WinForms)
	    class Demo1 : Form
    #else
    class Demo1 : CCTForm
#endif
    {

        int count;
        System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
        Button startButton = new Button();
        Button pauseButton = new Button();
        Button resetButton = new Button();
        ProgressBar pb = new ProgressBar();
        ListBox list = new ListBox();
        TextBox tb = new TextBox();
        DomainUpDown domain = new DomainUpDown();
        Label countDownLabel = new Label();
        Label bang = new Label();
        //SpriteStore sStore = new SpriteStore();


        public Demo1()
        {
            System.Collections.ArrayList alist = new System.Collections.ArrayList();
            string a = "David Ashton";
            string b = "Aaron Boyd";
            string c = "Pedro Ferrer";
            string d = "Dustin Shiflett";
            string e = "Batman";
            string f = "Superman";
            string g = "Aquaman";
            string h = "Spiderman";
            string i = "This Sucks";
            alist.Add(a);
            alist.Add(b);
            alist.Add(c);
            alist.Add(d);
            alist.Add(e);
            alist.Add(f);
            alist.Add(g);
            alist.Add(h);
            alist.Add(i);
            list.Items = alist;
            domain.Items = alist;
            domain.Location = new Point(170, 140);  
            list.Location = new Point(10, 140);
            tb.Location = new Point(170, 170);

            timer.Interval = 1000;
            timer.Tick += new EventHandler(timer_tick);

            startButton.Text = "start";
            startButton.Click += new EventHandler(startButton_Click);
            startButton.Location = new Point(20, 20);

            pauseButton.Text = "pause";
            pauseButton.Click += new EventHandler(pauseButton_Click);
            pauseButton.Location = new Point(20, 60);


            resetButton.Text = "reset";
            resetButton.Click += new EventHandler(resetButton_Click);
            resetButton.Location = new Point(20, 100);

            countDownLabel.Location = new Point(150, 65);

            bang.Font = new Font("SansSerif", 18);
            bang.Location = new Point(150, 20);
            bang.Text = "BANG";
            bang.Hide();

            pb.Step = 1;
            pb.Minimum = 0;
            pb.Maximum = 30;
            pb.Location = new Point(150, 100);

            count = 30;
            pb.Value = 30;
            countDownLabel.Text = "00:" + count;

            //sStore.Add("buzz.jpg");
            //sStore.setSprite("buzz.jpg");
            //sStore.Sprite.Location = new Point(200, 10);


#if (WinForms)
            	////Use these to run with Windows.Forms////
            	this.Controls.Add(startButton);
            	this.Controls.Add(pauseButton);
            	this.Controls.Add(resetButton);
            	this.Controls.Add(countDownLabel);
            	this.Controls.Add(pb);
            	this.Controls.Add(bang);
#else
            ///////Use these to run with CCT////////
            this.Add(startButton);
            this.Add(pauseButton);
            this.Add(resetButton);
            this.Add(countDownLabel);
            this.Add(pb);
            this.Add(list);
            this.Add(domain);
            this.Add(tb);
            this.Add(bang);
            //this.Add(sStore.Sprite);
#endif



        }

        void resetButton_Click(object sender, EventArgs e)
        {
            bang.Hide();
            count = 30;
            pb.Value = count;
            countDownLabel.Text = "00:" + count;
            this.Invalidate();
        }

        void pauseButton_Click(object sender, EventArgs e)
        {
            timer.Enabled = false;
        }

        void startButton_Click(object sender, EventArgs e)
        {
            timer.Enabled = true;
        }


        private void timer_tick(object sender, EventArgs e)
        {
            if (count > 0)
            {
                count--;
                pb.Value = count;
                countDownLabel.Text = "00:" + count;
                this.Invalidate();
            }
            else
            {
                timer.Enabled = false;
            }

            if (count == 0)
            {
                bang.Show();
            }
        }



        public static void Main()
        {
            System.Windows.Forms.Application.Run(new Demo1());
        }

        private void InitializeComponent()
        {
            this.SuspendLayout();
            // 
            // Demo1
            // 
            this.ClientSize = new System.Drawing.Size(284, 264);
            this.Name = "Demo1";
            this.ResumeLayout(false);

        }


    }
          
    
}
